/**
 * Created by hcadmin on 16/3/11.
 */

define([
    "jquery",
    "IO",
    "UPLOADUI",
    "UPLOAD",
    "jqueryUI",
    "bootbox",
    //"text!/js/biz/keb/activity/definebt.html"
], function ($, IO, upui, up, jui, bootbox, definebt) {



    $(".btn_sub").bind("click",function()
    {


        var alertarray = {
            form : {api:"/role/newRole",name:"alertform",id:"alertform"},
            inputs:[
                {title:"角色名",type:"text",placeholder:"",verify:"empty",name:"role_name",id:"role_name"}
            ]

        }
        bootbox.dialog({
            title : "新增角色",
            message :generateAlertForm(alertarray),
            buttons : {
                "success" : {
                    "label" : "<i class='icon-ok'></i> 保存",
                    "className" : "btn-sm btn-success",
                    "callback" : function() {

                        //验证
                        if(check_form_info_all(alertarray.form.name) == false)
                            return false;

                        //发送请求
                        ajax_request(alertarray.form.name,"",function process_data(data){


                            //操作成功
                            AlertSuccess(bootbox,"操作成功",function(){

                                jump("/role/rolelist");


                            });



                        },function process_fail(data){

                            //操作失败
                            AlertError(bootbox,data.msg);



                        });



                    }
                },
                "cancel" : {
                    "label" : "<i class='icon-info'></i> 取消",
                    "className" : "btn-sm btn-danger",
                    "callback" : function() { }
                }
            }
        });


        return;



        var form_name = get_form_name( $(this));
        //验证
        if(check_form_info_all(form_name) == false)
            return;

        //改变按钮状态
        $(this).html("提交中...");
        var btn = $(this);

        //发送请求
        ajax_request(form_name,"",function process_data(data){

            //操作成功
            AlertSuccess(bootbox,"操作成功",function(){

                jump("/role/rolelist");


            });


        },function process_fail(data){

            //操作失败
           AlertError(bootbox,data.msg,function(){  btn.html("提交"); });



        });

    });





});



